<div id="content">
  <div class="row s_page_title">
    <sa-big-breadcrumbs
      [items]="['日志信息管理', '海螺水泥推送日志']"
      icon="fa fa-truck"
      class="col-xs-12 col-sm-7 col-md-7 col-lg-4"
    ></sa-big-breadcrumbs>
  </div>
  <sa-widgets-grid>
    <div class="s_table">
      <div sa-widget [editbutton]="false" color="darken" class="clearfix">
        <header>
          <span class="widget-icon"><i class="fa fa-table"></i></span>
          <h2>海螺水泥推送日志</h2>
        </header>
        <div>
          <div class="widget-body no-padding">
            <div class="page-header clearfix s_table_opreation">
              <div class="left page-header-btn" style="width: calc(100% - 220px)">
                <sa-company-tree-car
                  companyTreeId="companyTree"
                  (companySelected)="companySelected($event)"
                ></sa-company-tree-car>
                <div class="top_module">
                  <span class="module_text">推送状态</span>
                  <select name="" id="" class="module_inp" [(ngModel)]="pushState">
                    <option value="">全部</option>
                    <option value="1">推送成功</option>
                    <option value="2">推送失败</option>
                  </select>
                </div>
                <div class="top_module">
                  <span class="module_text">推送类型</span>
                  <select name="" id="" class="module_inp" [(ngModel)]="pushMethodType">
                    <option value="">全部</option>
                    <option value="1">新增车辆</option>
                    <option value="2">修改IMEI</option>
                    <option value="3">修改车牌号</option>
                    <option value="4">设置服务截止日期</option>
                  </select>
                </div>
                <div class="top_module top_module_box">
                  <span class="module_text">海螺设备号</span>
                  <input
                    type="text"
                    class="module_inp top_module_select"
                    [(ngModel)]="haiLuoDeviceNo"
                    placeholder="海螺设备号"
                  />
                </div>
                <div class="selectDate top_module">
                  <table-select-date (outerTime)="getSelectTableTime($event)"></table-select-date>
                </div>

                <button type="button" class="btn btn-primary" (click)="table_search()">查询</button>
                <button type="button" class="btn btn-primary" (click)="pushAll()">批量推送</button>
                <button type="button" class="btn btn-primary" (click)="manualPush(manualPushModal)" *ngIf="isShowPush">
                  手动推送
                </button>
              </div>
              <div class="right top-search">
                <input
                  type="text"
                  [(ngModel)]="searchKey"
                  (change)="table_search()"
                  class="search-input"
                  placeholder="车牌号码、设备ID、海螺设备号..."
                />
                <span class="top-search-box">
                  <button class="top-search-btn" type="button" (click)="table_search()">
                    <i class="fa fa-search"></i>
                  </button>
                </span>
              </div>
            </div>
            <div class="table_scroll">
              <table
                class="display dataTables responsive table table-striped table-bordered table-hover dataTable s_h5_table"
              >
                <thead>
                  <tr>
                    <th>
                      <div class="checkbox" style="margin: 0; left: 5px; text-align: center">
                        <label>
                          <input
                            type="checkbox"
                            class="checkbox style-0"
                            [(ngModel)]="allChecked"
                            (click)="allSelected()"
                          />
                          <span></span>
                        </label>
                      </div>
                    </th>
                    <th>公司名称</th>
                    <th>车牌号码</th>
                    <th>设备ID</th>
                    <th>海螺设备号</th>
                    <th>推送类型</th>
                    <th>推送状态</th>
                    <th>推送时间</th>
                    <th>推送结果</th>
                    <th>操作</th>
                  </tr>
                </thead>
                <tbody>
                  <tr
                    *ngFor="let row of tableData; let i = index"
                    [attr.data-index]="i"
                    [ngClass]="{ selected: activeSelected === row.id }"
                  >
                    <td>
                      <div class="checkbox" style="margin: 0; left: 5px; text-align: center">
                        <label>
                          <input
                            type="checkbox"
                            class="checkbox style-0"
                            [(ngModel)]="row.isChecked"
                            [disabled]="row.pushMethodType == 3"
                            (click)="rowSelected(row, $event, i)"
                          />
                          <span></span>
                        </label>
                      </div>
                    </td>
                    <td>{{ row.companyName }}</td>
                    <td>{{ row.carNumber }}</td>
                    <td>{{ row.deviceId }}</td>
                    <td>{{ row.haiLuoDeviceNo }}</td>
                    <td>
                      <span *ngIf="row.pushMethodType == 1">新增车辆</span>
                      <span *ngIf="row.pushMethodType == 2">修改IMEI</span>
                      <span *ngIf="row.pushMethodType == 3">修改车牌号</span>
                      <span *ngIf="row.pushMethodType == 4">设置服务截止日期</span>
                    </td>
                    <td>
                      <span *ngIf="row.pushState == '2'" class="red">推送失败</span>
                      <span *ngIf="row.pushState == '1'" class="green">推送成功</span>
                    </td>
                    <td>{{ row.pushDate }}</td>
                    <td>{{ row.remark }}</td>
                    <td>
                      <button *ngIf="row.pushMethodType != 3" type="button" (click)="pushItem(row)">推送</button>
                    </td>
                  </tr>
                </tbody>
              </table>
            </div>
            <div class="table-fix clearfix">
              <paginator
                [totalRecords]="totalCount"
                [rows]="pageSize"
                [currentPage]="curPage - 1"
                (onPageChange)="paginate($event)"
              ></paginator>
              <button type="button" class="btn default refresh_btn" (click)="refresh()">
                <i class="fa fa-refresh"></i>
              </button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </sa-widgets-grid>
  <!-- 手动推送弹框 -->
  <section
    bsModal
    #manualPushModal="bs-modal"
    class="modal fade addRenewal"
    tabindex="-1"
    role="dialog"
    aria-labelledby="myLargeModalLabel"
    aria-hidden="true"
  >
    <div class="modal-dialog modal-lg" style="width: 1100px">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" (click)="closePushModal(manualPushModal)" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
          <h4 class="modal-title">手动推送</h4>
        </div>
        <div class="modal-body">
          <div class="row form-horizontal">
            <div  *ngFor="let item of pushData; let i = index">
              <div class="form-group">
                <label class="control-label col-xs-2 no-padding-right" style="width: 14.5%">{{ item.name }}:</label>
                <div class="col-xs-3" *ngFor="let list of item.dataList">
                  <input
                    id="{{i + list.key}}"
                    class="form-control"
                    [name]="list.key"
                    autocomplete="off"
                    [(ngModel)]="list.value"
                    type="text"
                    placeholder="{{ '请输入' + list.name }}"
                  />
                </div>
                <button type="button" class="col-xs-1 btn btn-primary no-padding-right" (click)="submitPush(i)">
                  推送
                </button>
            </div>
            <div class="form-group" *ngIf="item.name === '推送车辆载重+轨迹'">
              <label class="control-label col-xs-2 no-padding-right checkbox-label" style="width: 14.5%">
                  <input type="checkbox" class="checkbox style-0" [(ngModel)]='multiplePattern.isChecked'/>
                  <span class="checkbox-flag">倍数模式</span>
              </label>
              <div class="col-xs-3">
                <input
                  class="form-control"
                  [name]="wbWeight"
                  autocomplete="off"
                  [(ngModel)]="multiplePattern.wbWeight"
                  type="text"
                  placeholder="请输入满载重量,如10-30"
                  [disabled]="!multiplePattern.isChecked"
                />
              </div>
              <div class="col-xs-3">
                <input
                  id="wbDate"
                  class="form-control"
                  [name]="wbDate"
                  autocomplete="off"
                  [(ngModel)]="multiplePattern.wbDate"
                  type="text"
                  placeholder="请输入出厂时间(重磅时间)"
                  [disabled]="!multiplePattern.isChecked"
                />
              </div>
              <!-- <div class="col-xs-3" *ngFor="let list of item.dataList">
                  <input
                    class="form-control"
                    [name]="list.key"
                    autocomplete="off"
                    [(ngModel)]="list.value"
                    type="text"
                    placeholder="{{ '请输入' + list.name }}"
                  />
                </div> -->
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
</div>
